//
//  ZLAlert+ZLTextField.h
//  ZLAlert-OC
//
//  Created by 科大 on 2024/1/2.
//

#import "ZLAlert.h"

NS_ASSUME_NONNULL_BEGIN
typedef void (^ZLAlertEditChange)(NSString *text);
typedef void (^ZLAlertEditEnd)(NSString *text);

@interface ZLAlertTextField : UITextField
/// 编辑中回调
@property (nonatomic, copy) ZLAlertEditChange editChange;
/// 编辑完成回调
@property (nonatomic, copy) ZLAlertEditEnd editEnd;

/// 初始化
/// - Parameters:
///   - text: 默认内容
///   - placeholder: 提示语
///   - config: 配置
+ (instancetype)zl_textFieldWithText:(NSString *)text
                         placeholder:(NSString *)placeholder
                              config:(ZLAlertItemConfig *)config;

@end

@interface ZLAlert (ZLTextField)<UITextFieldDelegate>

/// 增加输入框使用默认配置
/// - Parameters:
///   - placeholder: 提示内容
///   - editEnd: 编辑完成回调
- (ZLAlert *)addTextField:(NSString *)placeholder
                  editEnd:(nullable ZLAlertEditEnd)editEnd;

/// 增加输入框自定义配置
/// - Parameters:
///   - text: 默认内容
///   - placeholder: 提示内容
///   - config: 配置
///   - editChange: 编辑回调
///   - editEnd: 编辑完成回调
- (ZLAlert *)addTextField:(NSString *)text
              placeholder:(NSString *)placeholder
                   config:(ZLAlertItemConfig *)config
               editChange:(nullable ZLAlertEditChange)editChange
                  editEnd:(nullable ZLAlertEditEnd)editEnd;
@end

NS_ASSUME_NONNULL_END
